import 'dart:developer';

import 'package:flutter/services.dart';

import '../index.dart';

class CommonMultiLineTextField extends BaseUpDownWidget {
  String? content;
  String? placeholder;
  int? maxLength;
  final ValueChanged<String>? onChanged;
  final TextEditingController _textEditingController = TextEditingController();

  CommonMultiLineTextField(
      {Key? key,
      this.content,
      this.placeholder,
      this.onChanged,
      this.maxLength,
      required title,
      isHideDivide = false,
      isRequired = false})
      : super(
            key: key,
            title: title,
            isHideDivide: isHideDivide,
            isRequired: isRequired);

  @override
  Widget build(BuildContext context) {
    _textEditingController.text = content ?? "";
    setDownWidget(TextField(
      controller: _textEditingController,
      keyboardType: TextInputType.multiline,
      textInputAction: TextInputAction.done,
      style: Theme.of(context).textTheme.bodyLarge,
      maxLines: 5,
      maxLength: maxLength,
      maxLengthEnforcement: MaxLengthEnforcement.truncateAfterCompositionEnds,
      decoration: InputDecoration(
          contentPadding: const EdgeInsets.all(10),
          // labelText: content,
          border: const OutlineInputBorder(),
          hintText: placeholder ?? "请输入"),
      onChanged: (String value) {
        content = value;
        if (onChanged != null) {
          onChanged!(value);
        }
      },
    ));
    return super.build(context);
  }
}
